package org.nf.shopping.controller;

import com.github.pagehelper.PageInfo;
import lombok.RequiredArgsConstructor;
import org.nf.shopping.common.vo.ResultVO;
import org.nf.shopping.entity.Employee;
import org.nf.shopping.service.EmployeeService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author czl
 * @Date 2024-12-02
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/employee")
public class EmployeeController extends BaseController{
    private final EmployeeService employeeService;

    @GetMapping("/listEmployee")
    public ResultVO<PageInfo<Employee>> employeePage(Integer limit, Integer page, String typeName){
        PageInfo<Employee> pageInfo = employeeService.employeePage(limit, page, typeName);
        return success(pageInfo);
    }

    @PostMapping("/updateEmployee")
    public ResultVO updateEmployee(Employee employee){
        employeeService.updateEmployee(employee);
        return success();
    }

    @PostMapping("/deloneEmployee")
    public ResultVO deloneEmployee(Integer id){
        employeeService.deloneEmployee(id);
        return success();
    }

    @PostMapping("/addEmployee")
    public ResultVO addEmployee(Employee employee){
        employeeService.addEmployee(employee);
        return success();
    }

    @PostMapping("/getEmployeeList")
    public ResultVO<List<Employee>> getEmployeeList(){
        return success(employeeService.getEmployeeList());
    }
}
